import requests

# 快代理后台生成的api链接   5s访问一次
# 提取代理API接口，获取1个代理IP
api_url = "https://dps.kdlapi.com/api/getdps/?secret_id=olrejp12b94qknshw4be&signature=m1y23gc6dg9ivkljppeovaaprqkqdgdh&num=1&pt=1&sep=1"

# 获取API接口返回的代理IP
proxy_ip = requests.get(api_url).text

print("获取新IP地址：", proxy_ip)

# 订单生成的账户与密码
username = "d2356162166"
password = "l7zee1jn"
url = "https://www.httpbin.org/get"
# 代理
proxies = {
    "http": f"http://{username}:{password}@{proxy_ip}",
    "https": f"http://{username}:{password}@{proxy_ip}",
}
response = requests.get(url, proxies=proxies)
print(response.content.decode())

"""
username = "d2356162166"
password = "l7zee1jn"
IP = "117.50.182.234:3128"
# 代理
proxies = {
    "http": f"http://{username}:{password}@{IP}",
    "https": f"http://{username}:{password}@{IP}",
}
"""